<#include "../public/header.html">
    <script type="text/javascript" src="public/js/datagrid-detailview.js"></script>
    <div id="editdlg"></div>
    <div id="editdlg_windows"></div>
    <div id="editdlg_student"></div>
    <div class="easyui-layout" style="width:100%;height:100%;">
        <div id="p" data-options="region:'west'" title="校区" style="width:20%;padding:10px">
            <ul id="tt" class="easyui-tree" data-options="url:'admin/department/combotree',method:'get',animate:true,onClick:tree_select,lines:true"></ul>
        </div>
        <div data-options="region:'center'" title="项目信息">
            <div id="seach_view">
                <div  style="padding:5px 5px; border-bottom: dashed #d2d2d2 1px;margin-bottom: 5px;">
                    项目编号: <input class="easyui-textbox" style="width:110px" id="project_code">
                    项目名称: <input class="easyui-textbox" style="width:110px" id="project_name">
                    <a href="javascript://" class="easyui-linkbutton" iconCls="icon-search" onclick="search_but()">搜索</a>
                </div>
                <table cellspacing="0" cellpadding="0">
                    <tbody>
                    <tr>
                       
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="add_project()" data-options="iconCls:'icon-add',disabled:'true',plain:'true',${((permission_button.p30101!) == 'true')? string('disabled:false','disabled:true')}" id="30101">新增计划</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="modify_project()" data-options="iconCls:'icon-edit',disabled:'true',plain:'true',${((permission_button.p30102!) == 'true')? string('disabled:false','disabled:true')}" id="30102">修改计划</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="up_project()" data-options="iconCls:'icon-report-go',disabled:'true',plain:'true',${((permission_button.p30104!) == 'true')? string('disabled:false','disabled:true')}" id="30104">提交计划</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="exa_project_()" data-options="iconCls:'icon-report-edit',disabled:'true',plain:'true',${((permission_button.p30103!) == 'true')? string('disabled:false','disabled:true')}" id="30103">审批计划</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="add_project_class()" data-options="iconCls:'icon-report-add',disabled:'true',plain:'true',${((permission_button.p30105!) == 'true')? string('disabled:false','disabled:true')}" id="30105">下发至班级</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="up_to_area_upload_file()" data-options="iconCls:'icon-report-go',disabled:'true',plain:'true',${((permission_button.p30107!) == 'true')? string('disabled:false','disabled:true')}" id="30107">学校提交资料核对</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="check_up_to_area_upload_file()" data-options="iconCls:'icon-report-edit',disabled:'true',plain:'true',${((permission_button.p30108!) == 'true')? string('disabled:false','disabled:true')}" id="30108">区域核对资料</a>
                        </td>
                    </tr>

                    </tbody>
                </table>
                <table cellspacing="0" cellpadding="0">
                    <tbody>
                    <tr>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="export_info()" data-options="iconCls:'icon-page-excel',disabled:'true',plain:'true',${((permission_button.p30110!) == 'true')? string('disabled:false','disabled:true')}">导出排班模板</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="_import_file()" data-options="iconCls:'icon-page-excel',disabled:'true',plain:'true',${((permission_button.p30111!) == 'true')? string('disabled:false','disabled:true')}">导入排班</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="export_result_info()" data-options="iconCls:'icon-page-excel',disabled:'true',plain:'true',${((permission_button.p30114!) == 'true')? string('disabled:false','disabled:true')}" >导出成绩模板</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="import_result_file()" data-options="iconCls:'icon-page-excel',disabled:'true',plain:'true',${((permission_button.p30115!) == 'true')? string('disabled:false','disabled:true')}">导入成绩</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="download_project_student()" data-options="iconCls:'icon-page-excel',disabled:'true',plain:'true',${((permission_button.p30115!) == 'true')? string('disabled:false','disabled:true')}">导出报考学生</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="download_project_student_pic()" data-options="iconCls:'icon-page-excel',disabled:'true',plain:'true',${((permission_button.p30115!) == 'true')? string('disabled:false','disabled:true')}">导出报考学生头相</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="print_dep_fz()" data-options="iconCls:'icon-prin',disabled:'true',plain:'true',${((permission_button.p30117!) == 'true')? string('disabled:false','disabled:true')}">打印</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="area_fz()" data-options="iconCls:'icon-book',disabled:'true',plain:'true',${((permission_button.p30118!) == 'true')? string('disabled:false','disabled:true')}">区发证</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="finish_project()" data-options="iconCls:'icon-ok',disabled:'true',plain:'true',${((permission_button.p30120!) == 'true')? string('disabled:false','disabled:true')} ">完成项目</a>
                        </td>
                        <td>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="cancel_project()" data-options="iconCls:'icon-delete',plain:'true',${((permission_button.p30121!) == 'true')? string('disabled:false','disabled:true')} ">终止项目</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
                <table id="list" class="easyui-datagrid" style="width:100%;height:100%"
                   sortName="id"
                   sortOrder="asc"
                   pagination="true"
                   pagesize="50"
                   singleSelect="true"
                   data-options="url:'admin/project/listJson',toolbar:'#seach_view'">
                <thead>
                <tr>
                    <th width="50"  field="look_d"  align="center" sortable="true" data-options="formatter:for_look_d">操作</th>
                    <th width="100" field="status_name"  align="center" sortable="true" data-options="formatter:for_status">当前环节</th>
                    <th width="100" field="dep_name"  align="center" sortable="true">单位名称</th>
                    <th width="100" field="project_code"  align="center" sortable="true">项目编号</th>
                    <th width="100" field="project_name"  align="center" sortable="true">项目名称</th>
                    <th width="120" field="project_is_upload_info_name"  align="center" sortable="true">报考资料</th>
                    <th width="120" field="project_payment_status_name"  align="center" sortable="true">缴费状态</th>
                    <th width="120" field="project_card_status_name"  align="center" sortable="true">发证状态</th>
                    <th width="100" field="project_rank_name"  align="center" sortable="true">项目级别</th>
                    <th width="140" field="project_type_name"  align="center" sortable="true">项目类别</th>
                    <th width="100" field="project_plan_begin_time"  align="center" sortable="true">计划开始时间</th>
                    <th width="100" field="project_plan_end_time" align="center" sortable="true">计划结束时间</th>
                    <th width="100" field="project_plan_user_num"  align="center" sortable="true">计划考试人数</th>
                    <th width="120" field="project_is_training_name"  align="center" sortable="true">考前培训</th>
                    <th width="100" field="project_is_temporary_place_name"  align="center" sortable="true">是否需要临时考场</th>
                    <th width="100" field="project_theory_time"  align="center" sortable="true">理论考试时间</th>
                    <th width="120" field="project_theory_place"  align="center" sortable="true">理论考试地点</th>
                    <th width="120" field="project_reality_time"  align="center" sortable="true">实操考试时间</th>
                    <th width="120" field="project_reality_place"  align="center" sortable="true">实操考试地址</th>
                    <th width="120" field="project_testing_money"  align="center" sortable="true">正考费用</th>
                    <th width="120" field="project_theory_money"  align="center" sortable="true">单理论</th>
                    <th width="120" field="project_reality_money"  align="center" sortable="true">单实操</th>
                    <th width="120" field="project_other_money"  align="center" sortable="true">其他费用</th>
                    <th width="120" field="project_register_num"  align="center" sortable="true">报考人数</th>
                    <th width="120" field="project_testing_num"  align="center" sortable="true">正考人数</th>
                    <th width="120" field="project_bk_theory_num"  align="center" sortable="true">补考理论人数</th>
                    <th width="120" field="project_bk_reality_num"  align="center" sortable="true">补考实操人数</th>
                    <th width="120" field="project_payment_num"  align="center" sortable="true">缴费人数</th>
                    <th width="120" field="project_payment_money"  align="center" sortable="true">缴费总数</th>
                    
                    <th width="120" field="create_user_name"  align="center" sortable="true">创建人</th>
                    <th width="140" field="create_time" align="center" sortable="true" data-options="formatter:function(value,row,index){
                         return formatDate(value);
                         } ">创建时间</th>
                </tr>
                </thead>
            </table>


        </div>
    </div>


    <script type="text/javascript">
        var content;
        var id ;
        var dep_id;
        $(function(){
            $("#seach_view").prependTo(".datagrid-toolbar");

            $('#list').datagrid({
                view: detailview,
                detailFormatter:function(index,row){
                    return '<div style="padding:2px;"><table class="ddv"></table></div>';
                },
                onExpandRow: function(index,row){
                    var project_status = row.status;
                    var ddv = $(this).datagrid('getRowDetail',index).find('table.ddv');
                    ddv.datagrid({
                        url:'admin/project_class/listJson?project_id='+row.id,
                        fitColumns:true,
                        singleSelect:true,
                        rownumbers:true,
                        pagination:true,
                        loadMsg:'',
                        columns:[[
                        	{field:'class_name',title:'报考班级',width:100,align:'center'},
                        	{field:'id',title:'操作',width:80,align:'center',formatter:function(value,row,index){
                                var str = '<a href="javascript:void(0)" class="easyui-linkbutton"  onclick="view_class_detail('+row.id+')" >查看</a> ';
                                var flag = "${permission_button.p30122!}";
                                if(row.status==249){
                                    str += ' <a href="javascript:void(0)" class="easyui-linkbutton" onclick="check_upload_file('+row.id+','+row.project_id+','+row.class_id+','+row.dep_id+','+row.status+')" >学校核对资料</a>';
                                }
                                if(project_status==253 && row.status >= 251 ){
                                    str += ' <a href="javascript:void(0)" class="easyui-linkbutton" onclick="back_to_class_file('+row.id+','+row.project_id+','+row.class_id+','+row.dep_id+','+row.status+')" >退回</a>';
                                }
                                if(project_status==262 || row.status == 263){
                                    str += ' <a href="javascript:void(0)" class="easyui-linkbutton" onclick="print_fz('+row.id+')" >打印发证表</a>';
                                }
                                if(project_status>=262 && row.status <= 265){
                                    str += ' <a href="javascript:void(0)" class="easyui-linkbutton" onclick="student_get_card('+row.id+')" >学校确认学生收证</a>';
                                }
                                if(flag == "true"){
                                    str += ' <a href="javascript:void(0)" class="easyui-linkbutton" onclick="del_project_class('+row.id+')" >删除</a>';
                                }
                                return str;
                            }},
                            
                            {field:'project_name',title:'项目名称',width:100,align:'center'},
                            {field:'status_name',title:'当前状态',width:100,align:'center',formatter:for_class_status},
                             {field:'project_is_upload_info_name',title:'报考资料',width:100,align:'center'},
                            {field:'project_payment_status_name',title:'缴费状态',width:100,align:'center'},
                            {field:'project_card_status_name',title:'发证状态',width:100,align:'center'},
                            
                            {field:'project_rank_name',title:'项目级别',width:100,align:'center'},
                            {field:'project_testing_money',title:'正考费用',width:100,align:'center'},
                            {field:'project_theory_money',title:'单理论',width:100,align:'center'},
                            {field:'project_reality_money',title:'单实操',width:100,align:'center'},
                            {field:'project_register_num',title:'报考人数',width:100,align:'center'},
                            {field:'project_testing_num',title:'正考人数',width:100,align:'center'},
                            {field:'project_bk_theory_num',title:'补考理论人数',width:100,align:'center'},
                            {field:'project_bk_reality_num',title:'补考实操人数',width:100,align:'center'},
                            {field:'project_payment_num',title:'缴费人数',width:100,align:'center'},
                            {field:'project_payment_money',title:'缴费总数',width:100,align:'center'},
                           
                            {field:'user_name',title:'创建用户',width:100,align:'center'},
                            {field:'create_time',title:'创建时间',width:100,align:'center',formatter:function(value,row,index){
                                return formatDate(value);
                            }}
                            
                        ]],
                        onResize:function(){
                            $('#list').datagrid('fixDetailRowHeight',index);
                        },
                        onLoadSuccess:function(){
                            setTimeout(function(){
                                $('#list').datagrid('fixDetailRowHeight',index);
                            },0);
                        }
                    });
                    $('#dg').datagrid('fixDetailRowHeight',index);
                }
            });
        });

        var download_project_student = function (){
            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }
            window.open("${root!}admin/project_student/download_project_student?project_id="+note.id);
        }
        var download_project_student_pic = function (){
            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }
            window.open("${root!}admin/project_file/download_pic_zip?id="+note.id);
        }

        var del_project_class = function (id) {

            $.messager.confirm('警告', '确定删除这个班级数据吗？删除后将无法恢复！', function(r){
                if (r){
                    $.ajax({
                        type:"post",
                        url:"admin/project_class/del_project_class",
                        data:{project_class_id:id},
                        dataType:"JSON",
                        success:function(data){
                            $.messager.alert("提示",data.msg);
                            $("table.ddv").datagrid("reload");
                        }
                    })
                }
            });
        }
        var finish_project = function () {
            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            if(note.status <= 265){
                $.messager.show({
                    title:'提醒',
                    msg:'当前状态不能完成此项目',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            $.messager.confirm('提示', '确定完成此项目吗？', function(r){
                if (r){
                    $.ajax({
                        type:"post",
                        url:"admin/project/finish_project",
                        data:{project_id:note.id},
                        dataType:"JSON",
                        success:function(data){
                            $.messager.alert("提示",data.msg);
                            $("#list").datagrid("reload");
                        }
                    })
                }
            });
        }

        var cancel_project = function () {
            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }


            $.messager.confirm('提示', '确定终止此项目吗？终止后将无法恢复', function(r){
                if (r){
                    $.ajax({
                        type:"post",
                        url:"admin/project/cancel_project",
                        data:{project_id:note.id},
                        dataType:"JSON",
                        success:function(data){
                            $.messager.alert("提示",data.msg);
                            $("#list").datagrid("reload");
                        }
                    })
                }
            });
        }

        var student_get_card = function (id) {

            $("#editdlg").window({
                title: "班级报考学生",
                iconCls: 'icon-edit',
                width: 700,
                height: 500,
                closed: false,
                cache: false,
                modal: true,
                href: "admin/project_class/student_get_card?project_class_id="+id,
                onLoad: function () {
                    $.messager.progress('close');
                },
                buttons:null
            });
        }

        var print_fz = function (id) {

            $("#editdlg").dialog({
                title: "打印领证信息表",
                iconCls: 'icon-prin',
                width: '100%',
                height: '100%',
                closed: false,
                cache: false,
                modal: true,
                href: "admin/project_class/print_fz?project_class_id="+id,
                onLoad: function () {
                    $.messager.progress('close');
                },
                buttons:[{
                    text: '取消',
                    iconCls:'icon-cancel',
                    handler: function () {
                        $("#editdlg").dialog("close");
                    }
                },{
                    text: '打印',
                    iconCls: 'icon-prin',
                    handler: function(){
                        doPrint();
                    }
                }]
            });
        }

        var area_fz = function () {
            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            if(note.status != 261){
                $.messager.show({
                    title:'提醒',
                    msg:'当前状态不能执行发证书',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            $.messager.confirm('提示', '确定证书已下发到学校了吗？', function(r){
                if (r){
                    $.ajax({
                        type:"post",
                        url:"admin/project/area_fz",
                        data:{project_id:note.id},
                        dataType:"JSON",
                        success:function(data){
                            $.messager.alert("提示",data.msg);
                            $("#list").datagrid("reload");
                        }
                    })
                }
            });
        }

        var print_dep_fz = function () {
            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            $("#editdlg").dialog({
                title: "打印领证信息表",
                iconCls: 'icon-prin',
                width: '100%',
                height: '100%',
                closed: false,
                cache: false,
                modal: true,
                href: "admin/project/print_dep_fz?project_id="+note.id,
                onLoad: function () {
                    $.messager.progress('close');
                },
                buttons:[{
                    text: '取消',
                    iconCls:'icon-cancel',
                    handler: function () {
                        $("#editdlg").dialog("close");
                    }
                },{
                    text: '打印',
                    iconCls: 'icon-prin',
                    handler: function(){
                        doPrint();
                    }
                }]
            });
        }

        var export_result_info = function (){
            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }
            window.open("${root!}admin/project/export_cjmb?id="+note.id);
        }

        var export_info = function (){
            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }
            window.open("${root!}admin/project/export_pbmb?id="+note.id);
        }

        var import_result_file = function (){

            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            $("#editdlg_windows").dialog({
                title: "导入成绩",
                iconCls: 'icon-edit',
                width: 400,
                height: 200,
                closed: false,
                cache: false,
                modal: true,
                href: "admin/project/import_testing?project_id="+note.id,
                onLoad: function () {
                    $.messager.progress('close');
                },
                buttons: [{
                    text: '取消',
                    iconCls:'icon-cancel',
                    handler: function () {
                        $("#editdlg_windows").dialog("close");
                    }
                },{
                    text: '导入',
                    iconCls: 'icon-back',
                    handler: function(){
                        $('#import_file_Form').form('submit',{
                            url:"admin/project/impdata_cj",
                            dataType:"json",
                            onSubmit:function(){
                                return $(this).form('enableValidation').form('validate');
                            },
                            success:function(data){
                                var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                $.messager.alert("提示",data.msg);
                                if(data.success==1){
                                    $('#back_to_class_fileForm').form('clear');
                                    $("#editdlg_windows").dialog("close");
                                    $("#list").datagrid("reload");
                                }
                            }
                        });

                    }

                }]
            });
        }

        var _import_file = function (){

            var note =  $("#list").datagrid("getSelected");
            if(note == null ){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            if(note.status >= 260 ){
                $.messager.show({
                    title:'提醒',
                    msg:'当前环节不能导入考试信息',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            $("#editdlg_windows").dialog({
                title: "导入考试信息",
                iconCls: 'icon-edit',
                width: 400,
                height: 200,
                closed: false,
                cache: false,
                modal: true,
                href: "admin/project/import_testing?project_id="+note.id,
                onLoad: function () {
                    $.messager.progress('close');
                },
                buttons: [{
                    text: '取消',
                    iconCls:'icon-cancel',
                    handler: function () {
                        $("#editdlg_windows").dialog("close");
                    }
                },{
                    text: '导入',
                    iconCls: 'icon-back',
                    handler: function(){
                        $('#import_file_Form').form('submit',{
                            url:"admin/project/impdata",
                            dataType:"json",
                            onSubmit:function(){
                                return $(this).form('enableValidation').form('validate');
                            },
                            success:function(data){
                                var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                $.messager.alert("提示",data.msg);
                                if(data.success==1){
                                    $('#back_to_class_fileForm').form('clear');
                                    $("#editdlg_windows").dialog("close");
                                    $("#list").datagrid("reload");
                                }
                            }
                        });

                    }

                }]
            });
        }

        var view_project_detail = function () {
            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要查看的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }
            
            $("#editdlg_windows").window({
                title: "项目详细",
                iconCls: 'icon-edit',
                width: 700,
                height: 500,
                closed: false,
                cache: false,
                modal: true,
                href: "admin/project/project_detail?project_id="+note.id,
                onLoad: function () {
                    $.messager.progress('close');
                }
            });
        }
        
        
        function look_project_detail(pid) {
            
            
            $("#editdlg_windows").window({
                title: "项目详细",
                iconCls: 'icon-edit',
                width: '100%',
                height: '100%',
                closed: false,
                cache: false,
                modal: true,
                href: "admin/project/project_detail?project_id="+pid,
                onLoad: function () {
                    $.messager.progress('close');
                }
            });
        }

        function for_class_status(val,row){
            return "<a onclick='class_status_onclick("+row.project_id+","+row.class_id+",291)'>"+val+"</a>";
        }

        function class_status_onclick(project_id,class_id,type){
            $.messager.progress({
                text:'数据加载中....',
                interval:100
            });

            $("#editdlg").dialog({
                title:"查询状态记录",
                iconCls: 'icon-edit',
                width: 700,
                height: 400,
                closed: false,
                cache: false,
                modal: true,
                href:"admin/project_examination/project_record?project_id="+project_id+"&exa_type="+type+"&class_id="+class_id,
                onLoad:function() {
                    $.messager.progress('close');
                },
                buttons: []
            });
        }

        function search_but(){
            $("#list").datagrid("reload",{project_name:$("#project_name").val(),project_code:$("#project_code").val()});
        }

        function tree_select(note){
            dep_id = note.id;
            $("#list").datagrid("reload",{student_name:$("#student_name").val(),student_id_cart:$("#student_id_cart").val(),dep_id:dep_id,type:note.type});
        }

        var view_class_detail = function (id) {
            $("#editdlg_windows").window({
                title: "班级报考详细",
                iconCls: 'icon-edit',
                width: '100%',
                height: '100%',
                closed: false,
                cache: false,
                modal: true,
                href: "admin/project_class/class_detail?project_class_id="+id,
                onLoad: function () {
                    $.messager.progress('close');
                }
            });
        }

        var check_upload_file = function (id,project_id,class_id,dep_id,status) {

            $.ajax({
                url:"admin/project_examination/check_upload_file_permisson",
                data:{project_id:project_id,class_id:class_id,dep_id:dep_id,status:status},
                dataType:"json",
                success:function(data){
                    $.messager.progress("close");
                    if(data.state == 0){
                        $.messager.show({
                            title:'提醒',
                            msg:data.msg,
                            showType:'fade',
                            style:{right:'',bottom:''}
                        });
                    }else{
                        $("#editdlg_windows").dialog({
                            title: "学校核对资料",
                            iconCls: 'icon-edit',
                            width: 700,
                            height: 300,
                            closed: false,
                            cache: false,
                            modal: true,
                            href: "admin/project_examination/check_upload_file?project_class_id="+id+"&exa_type=291",
                            onLoad: function () {
                                $.messager.progress('close');
                            },
                            buttons: [{
                                text: '取消',
                                iconCls:'icon-cancel',
                                handler: function () {
                                    $("#editdlg_windows").dialog("close");
                                }
                            },{
                                text: '退回',
                                iconCls: 'icon-back',
                                handler: function(){
                                    $.messager.confirm('信息确认', '是否确定要退回吗？', function(r){
                                        if (r){
                                            $('#check_upload_fileForm').form('submit',{
                                                url:"admin/project_examination/check_upload_file_back",
                                                dataType:"json",
                                                onSubmit:function(){
                                                    return $(this).form('enableValidation').form('validate');
                                                },
                                                success:function(data){
                                                    var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                                    $.messager.alert("提示",data.msg);
                                                    if(data.success==1){
                                                        $('#check_upload_fileForm').form('clear');
                                                        $("#editdlg_windows").dialog("close");
                                                        $(".ddv").datagrid("reload");
                                                    }
                                                }
                                            });
                                        }
                                    });
                                }

                            },{
                                text: '校对通过',
                                iconCls: 'icon-ok',
                                handler: function(){

                                    $.messager.confirm('信息确认', '是否确定要通过审批吗？', function(r){
                                        if (r){
                                            $('#check_upload_fileForm').form('submit',{
                                                url:"admin/project_examination/check_upload_file_go",
                                                dataType:"json",
                                                onSubmit:function(){
                                                    return $(this).form('enableValidation').form('validate');
                                                },
                                                success:function(data){
                                                    var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                                    $.messager.alert("提示",data.msg);
                                                    if(data.success==1){
                                                        $('#check_upload_fileForm').form('clear');
                                                        $("#editdlg_windows").dialog("close");
                                                        $(".ddv").datagrid("reload");
                                                    }
                                                }
                                            });
                                        }
                                    });
                                }

                            }]
                        });
                    }
                }
            });

        }

        var back_to_class_file = function (id,project_id,class_id,dep_id,status) {
            $("#editdlg_windows").dialog({
                title: "学校退回班级",
                iconCls: 'icon-edit',
                width: 700,
                height: 300,
                closed: false,
                cache: false,
                modal: true,
                href: "admin/project_examination/back_to_class_file?project_class_id="+id+"&exa_type=291",
                onLoad: function () {
                    $.messager.progress('close');
                },
                buttons: [{
                    text: '取消',
                    iconCls:'icon-cancel',
                    handler: function () {
                        $("#editdlg_windows").dialog("close");
                    }
                },{
                    text: '退回',
                    iconCls: 'icon-back',
                    handler: function(){
                        $.messager.confirm('信息确认', '是否确定要退回吗？', function(r){
                            if (r){
                                $('#back_to_class_fileForm').form('submit',{
                                    url:"admin/project_examination/back_to_class_file_save",
                                    dataType:"json",
                                    onSubmit:function(){
                                        return $(this).form('enableValidation').form('validate');
                                    },
                                    success:function(data){
                                        var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                        $.messager.alert("提示",data.msg);
                                        if(data.success==1){
                                            $('#back_to_class_fileForm').form('clear');
                                            $("#editdlg_windows").dialog("close");
                                            $(".ddv").datagrid("reload");
                                        }
                                    }
                                });
                            }
                        });
                    }

                }]
            });
        }

        var up_to_area_upload_file = function(){
            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            if(note.status != 251 && note.status != 253){
                $.messager.show({
                    title:'提醒',
                    msg:'当前状态不能提交',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            if(note.project_payment_status != 321){
                $.messager.show({
                    title:'提醒',
                    msg:'未确认收费，不参提交',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            $.messager.progress({
                text:'数据加载中....',
                interval:100
            });

            $("#editdlg").dialog({
                title:"学校提交资料核对",
                iconCls: 'icon-edit',
                width: 700,
                height: 300,
                closed: false,
                cache: false,
                modal: true,
                href:"admin/project_examination/up_to_area_upload_file?project_id="+note.id+"&exa_type=290",
                onLoad:function() {
                    $.messager.progress('close');
                },
                buttons: [{
                    text: '取消',
                    iconCls:'icon-cancel',
                    handler: function () {
                        $('#up_to_area_upload_fileFrom').form('clear');
                        $("#editdlg").dialog("close");
                    }
                },{
                    text: '提交',
                    iconCls: 'icon-ok',
                    handler: function(){
                        $('#up_to_area_upload_fileFrom').form('submit',{
                            url:"admin/project_examination/up_to_area_upload_file_save",
                            dataType:"json",
                            onSubmit:function(){
                                return $(this).form('enableValidation').form('validate');
                            },
                            success:function(data){
                                var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                $.messager.alert("提示",data.msg);
                                if(data.success==1){
                                    $("#editdlg").dialog("close");
                                    $("#list").datagrid("reload");
                                }
                            }
                        });
                    }

                }]
            });
        }

        var check_up_to_area_upload_file = function () {

            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            if(note.status != 252){
                $.messager.show({
                    title:'提醒',
                    msg:'当前状态不能审批',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            $.messager.progress({
                text:'数据加载中....',
                interval:100
            });

            $.ajax({
                url:"admin/project_examination/check_permisson",
                data:{project_id:note.id,status:note.status},
                dataType:"json",
                success:function(data){
                    $.messager.progress("close");
                    if(data.state == 0){
                        $.messager.show({
                            title:'提醒',
                            msg:data.msg,
                            showType:'fade',
                            style:{right:'',bottom:''}
                        });
                    }else{
                        $("#editdlg_windows").dialog({
                            title: "区域核对资料",
                            iconCls: 'icon-edit',
                            width: 700,
                            height: 300,
                            closed: false,
                            cache: false,
                            modal: true,
                            href: "admin/project_examination/check_up_to_area_upload_file?project_id="+note.id+"&exa_type=290",
                            onLoad: function () {
                                $.messager.progress('close');
                            },
                            buttons: [{
                                text: '取消',
                                iconCls:'icon-cancel',
                                handler: function () {
                                    $("#editdlg_windows").dialog("close");
                                }
                            },{
                                text: '退回',
                                iconCls: 'icon-back',
                                handler: function(){
                                    $.messager.confirm('信息确认', '是否确定要退回吗？', function(r){
                                        if (r){
                                            $('#check_up_to_area_upload_fileFrom').form('submit',{
                                                url:"admin/project_examination/check_up_to_area_upload_file_back",
                                                dataType:"json",
                                                onSubmit:function(){
                                                    return $(this).form('enableValidation').form('validate');
                                                },
                                                success:function(data){
                                                    var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                                    $.messager.alert("提示",data.msg);
                                                    if(data.success==1){
                                                        $('#check_up_to_area_upload_fileFrom').form('clear');
                                                        $("#editdlg_windows").dialog("close");
                                                        $("#list").datagrid("reload");
                                                    }
                                                }
                                            });
                                        }
                                    });
                                }

                            },{
                                text: '校对通过',
                                iconCls: 'icon-ok',
                                handler: function(){

                                    $.messager.confirm('信息确认', '是否确定要通过审批吗？', function(r){
                                        if (r){
                                            $('#check_up_to_area_upload_fileFrom').form('submit',{
                                                url:"admin/project_examination/check_up_to_area_upload_file_go",
                                                dataType:"json",
                                                onSubmit:function(){
                                                    return $(this).form('enableValidation').form('validate');
                                                },
                                                success:function(data){
                                                    var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                                    $.messager.alert("提示",data.msg);
                                                    if(data.success==1){
                                                        $('#check_up_to_area_upload_fileFrom').form('clear');
                                                        $("#editdlg_windows").dialog("close");
                                                        $("#list").datagrid("reload");
                                                    }
                                                }
                                            });
                                        }
                                    });
                                }

                            }]
                        });
                    }
                }
            });

        }

        var  add_project = function (){
            $("#editdlg").dialog({
                title:"制定计划",
                iconCls: 'icon-edit',
                width: 700,
                height: 400,
                closed: false,
                cache: false,
                modal: true,
                href:"admin/project/edit",
                onLoad:function() {
                    $.messager.progress('close');
                    if(dep_id !== undefined){
                        $("#dep_id").combotree("setValue",dep_id);
                    }
                },
                buttons: [{
                    text: '取消',
                    iconCls:'icon-cancel',
                    handler: function () {
                        $('#editForm').form('clear');
                        $("#editdlg").dialog("close");
                    }
                },{
                    text: '保存',
                    iconCls: 'icon-ok',
                    handler: save
                }]
            });
        }

        var modify_project = function(){
            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            if(note.status != 241 && note.status != 243){
                $.messager.show({
                    title:'提醒',
                    msg:'当前状态不能修改',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            $.messager.progress({
                text:'数据加载中....',
                interval:100
            });

            $("#editdlg").dialog({
                title:"修改计划",
                iconCls: 'icon-edit',
                width: 700,
                height: 400,
                closed: false,
                cache: false,
                modal: true,
                href:"admin/project/edit?id="+note.id,
                onLoad:function() {
                    $.messager.progress('close');

                },
                buttons: [{
                    text: '取消',
                    iconCls:'icon-cancel',
                    handler: function () {
                        $('#editForm').form('clear');
                        $("#editdlg").dialog("close");
                    }
                },{
                    text: '保存',
                    iconCls: 'icon-ok',
                    handler: save
                }]
            });
        }

        var up_project = function(){
            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            if(note.status != 241 && note.status != 243){
                $.messager.show({
                    title:'提醒',
                    msg:'当前状态不能提交',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            $.messager.progress({
                text:'数据加载中....',
                interval:100
            });

            $("#editdlg").dialog({
                title:"提交计划",
                iconCls: 'icon-edit',
                width: 700,
                height: 400,
                closed: false,
                cache: false,
                modal: true,
                href:"admin/project_examination/project_up?project_id="+note.id+"&exa_type=290",
                onLoad:function() {
                    $.messager.progress('close');
                },
                buttons: [{
                    text: '取消',
                    iconCls:'icon-cancel',
                    handler: function () {
                        $('#editForm').form('clear');
                        $("#editdlg").dialog("close");
                    }
                },{
                    text: '提交',
                    iconCls: 'icon-ok',
                    handler: function(){
                        $('#upForm').form('submit',{
                            url:"admin/project_examination/project_up_save",
                            dataType:"json",
                            onSubmit:function(){
                                return $(this).form('enableValidation').form('validate');
                            },
                            success:function(data){
                                var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                $.messager.alert("提示",data.msg);
                                if(data.success==1){
                                    $("#editdlg").dialog("close");
                                    $("#list").datagrid("reload");
                                }
                            }
                        });
                    }

                }]
            });
        }

        var exa_project_ = function(){
            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            if(note.status != 242){
                $.messager.show({
                    title:'提醒',
                    msg:'当前状态不能审核',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            $.messager.progress({
                text:'权限校验中....',
                interval:100
            });

            $.ajax({
                url:"admin/project_examination/check_permisson",
                data:{project_id:note.id,status:note.status},
                dataType:"json",
                success:function(data){
                    $.messager.progress("close");
                    if(data.state == 0){
                        $.messager.show({
                            title:'提醒',
                            msg:data.msg,
                            showType:'fade',
                            style:{right:'',bottom:''}
                        });
                    }else{
                        exa_project(note)
                    }
                }
            });
        }

        var add_project_class = function(){
            var note =  $("#list").datagrid("getSelected");
            if(note == null){
                $.messager.show({
                    title:'提醒',
                    msg:'请选择要编缉的行',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            if(note.status < 244){
                $.messager.show({
                    title:'提醒',
                    msg:'当前状态不能审核',
                    showType:'fade',
                    style:{
                        right:'',
                        bottom:''
                    }
                });
                return;
            }

            $("#editdlg").dialog({
                title:"下发到班级",
                iconCls: 'icon-edit',
                width: 700,
                height: 400,
                closed: false,
                cache: false,
                modal: true,
                href:"admin/class/add_project_class?project_id="+note.id+"&dep_id="+note.dep_id,
                onLoad:function() {
                    $.messager.progress('close');
                },
                buttons: [{
                    text: '取消',
                    iconCls:'icon-cancel',
                    handler: function () {
                        $("#editdlg").dialog("close");
                    }
                },{
                    text: '确定下发',
                    iconCls: 'icon-ok',
                    handler: function(){
                        var classes = $("#add_class_area").datagrid("getSelections");
                        var classes_str = "";
                        $.each(classes,function(i,item){
                           if(i==0){
                               classes_str +=item.id;
                           }else{
                               classes_str +=","+item.id;
                           }
                        });


                        $.ajax({
                            type:"post",
                            url:"admin/project_class/add_to_class",
                            data:{project_id:note.id,classes:classes_str},
                            dataType:"json",
                            success:function(data){
                                $.messager.alert("提示",data.msg);
                                if(data.success == 1){
                                    $("#editdlg").dialog("close");
                                    $("#list").datagrid("reload");
                                }
                            },
                            error:function(data){
                                $.messager.alert("提示",data);
                            }
                        });
                    }

                }]
            });

        }

        function save(){
            $('#editForm').form('submit',{
                url:"admin/project/save",
                dataType:"json",
                onSubmit:function(){
                    return $(this).form('enableValidation').form('validate');
                },
                success:function(data){
                    var data = eval('(' + data + ')');  // change the JSON string to javascript object

                    $.messager.alert("提示",data.msg);
                    if(data.success==1){
                        $("#editdlg").dialog("close");
                        $("#list").datagrid("reload");
                    }
                }
            });
        }

        function for_status(val,row){
            return "<a onclick='status_onclick("+row.id+",290)'>"+val+"</a>";
        }
        
        function for_look_d(val,row){
            return "<a href='javascript:void(0)' class='easyui-linkbutton' onclick='look_project_detail("+row.id+")'>查看</a>";
        }
        
 

        function status_onclick(project_id,type){
            $.messager.progress({
                text:'数据加载中....',
                interval:100
            });

            $("#editdlg").dialog({
                title:"查询状态记录",
                iconCls: 'icon-edit',
                width: 700,
                height: 400,
                closed: false,
                cache: false,
                modal: true,
                href:"admin/project_examination/project_record?project_id="+project_id+"&exa_type="+type,
                onLoad:function() {
                    $.messager.progress('close');
                },
                buttons:[]
            });
        }

        function exa_project(note){
            $("#editdlg").dialog({
                title:"审批计划",
                iconCls: 'icon-edit',
                width: 700,
                height: 500,
                closed: false,
                cache: false,
                modal: true,
                href:"admin/project_examination/exa_project?project_id="+note.id+"&exa_type=290",
                onLoad:function() {
                    $.messager.progress('close');
                    // 打开Dialog后创建编辑器
                    content=KindEditor.create('#project_introdution', {
                        resizeType : 1,
                        allowFileManager: true
                    });
                },
                onBeforeClose: function (event, ui) {
                // 关闭Dialog前移除编辑器
                    KindEditor.remove('#project_introdution');
                },
                buttons: [{
                    text: '取消',
                    iconCls:'icon-cancel',
                    handler: function () {
                        $('#editForm').form('clear');
                        $("#editdlg").dialog("close");
                    }
                },{
                    text: '退回',
                    iconCls: 'icon-back',
                    handler: function(){
                        var explanation = $("#explanation").textbox("getValue");

                        if(explanation == ""){
                            $.messager.show({
                                title:'提醒',
                                msg:'请填写审批意见',
                                showType:'fade',
                                style:{
                                    right:'',
                                    bottom:''
                                }
                            });
                            return;
                        }
                        $.messager.confirm('信息确认', '是否确定要退回吗？', function(r){
                            if (r){
                                $('#exa_project_Form').form('submit',{
                                    url:"admin/project_examination/exa_area_back",
                                    dataType:"json",
                                    onSubmit:function(){
                                        return $(this).form('enableValidation').form('validate');
                                    },
                                    success:function(data){
                                        var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                        $.messager.alert("提示",data.msg);
                                        if(data.success==1){
                                            $('#exa_project_Form').form('clear');
                                            $("#editdlg").dialog("close");
                                            $("#list").datagrid("reload");
                                        }
                                    }
                                });
                            }
                        });
                    }

                },{
                    text: '审批通过',
                    iconCls: 'icon-ok',
                    handler: function(){
                        var explanation = $("#explanation").textbox("getValue");
                        var project_code = $("#project_code_ss").textbox("getValue");

                        if(explanation == ""){
                            $.messager.show({
                                title:'提醒',
                                msg:'请填写审批意见',
                                showType:'fade',
                                style:{
                                    right:'',
                                    bottom:''
                                }
                            });
                            return;
                        }

                        if(project_code == ""){
                            $.messager.show({
                                title:'提醒',
                                msg:'请生成项目编号',
                                showType:'fade',
                                style:{
                                    right:'',
                                    bottom:''
                                }
                            });
                            return;
                        }

                        $.messager.confirm('信息确认', '是否确定要通过审批吗？', function(r){
                            if (r){
                                $('#exa_project_Form').form('submit',{
                                    url:"admin/project_examination/exa_area_through",
                                    dataType:"json",
                                    onSubmit:function(){
                                        $("#project_introdution").text(content.html());

                                        return $(this).form('enableValidation').form('validate');
                                    },
                                    success:function(data){
                                        var data = eval('(' + data + ')');  // change the JSON string to javascript object

                                        $.messager.alert("提示",data.msg);
                                        if(data.success==1){
                                            $('#exa_project_Form').form('clear');
                                            $("#editdlg").dialog("close");
                                            $("#list").datagrid("reload");
                                        }
                                    }
                                });
                            }
                        });
                    }

                }]
            });
        }


    </script>
<#include "../public/footer.html">